//
//  MainTopicSingleImageCell.m
//  ZITHER
//
//  Created by 吴凡 on 2019/2/14.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "MainTopicSingleImageCell.h"

@implementation MainTopicSingleImageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    _TopicContentView.layer.borderColor = [UIColor colorWithHex:@"#CCCCCC"].CGColor;
    _TopicContentView.layer.borderWidth = .5f;
    _avatarImageView.layer.masksToBounds = YES;
    _avatarImageView.layer.cornerRadius = 2.f;
    _ugcAvatarImageView.layer.masksToBounds = YES;
    _ugcAvatarImageView.layer.cornerRadius = 15.f;
}
- (void)setModel:(TopicSubModel *)model {
    _model = model;
    
    // avatar
    NSURL *avatarUrl;
    if (_model.userSubjectImages.count > 0) {
        avatarUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",RootUrlImage,_model.userSubjectImages[0].url]];
    } else {
        avatarUrl = [NSURL URLWithString:@""];
    }
    NSURL *ugcAvatarUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",RootUrlImage,_model.userUgc.avatar]];
    [_avatarImageView sd_setImageWithURL:avatarUrl placeholderImage:[UIImage imageNamed:@""]];
    [_ugcAvatarImageView sd_setImageWithURL:ugcAvatarUrl placeholderImage:[UIImage imageNamed:@""]];
    
    // topic
    _topicLabel.text = [NSString stringWithFormat:@"     %@",_model.title];
    _topicNumberLabel.text = [NSString stringWithFormat:@"%@人正在讨论",_model.correlationUserCount];
    
    // ugc
    _ugcNickNameLabel.text = [NSString stringWithFormat:@"%@",_model.userUgc.nickName];
    _ugcNumberLabel.text = [NSString stringWithFormat:@"%@条评论",_model.userUgc.commentCount];
    if (!_model.userUgc.ugcContent || [_model.userUgc.ugcContent isEqualToString:@""]) {
        _ugcContentLabel.hidden = YES;
    } else {
        _ugcContentLabel.hidden = NO;
        _ugcContentLabel.text = [NSString stringWithFormat:@"%@",_model.userUgc.ugcContent];
    }
    
    
    // ugc image
    NSURL *imageUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",RootUrlImage,_model.userUgc.fileList[0]]];
    [_ugcImage sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"ucg_img_loding"]];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
